﻿using System;
using System.Xml.Linq;
using HigLabo.Net.Extensions;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using Newtonsoft.Json.Linq;

namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class SearchMetaData : ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        public Int64 MaxID { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Int64 SinceID { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String SinceIDString { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String RefreshUrl { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String NextResults { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Int32 Count { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Double CompletedIn { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String Query { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public String MaxIDString { set; get; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public SearchMetaData(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(string jsonText)
        {
            var d = this.SetData(jsonText);

            this.MaxID = d.ToInt64("max_id") ?? this.MaxID;
            this.MaxIDString = d.ToString("max_id_str");
            this.SinceID = d.ToInt64("since_id") ?? this.MaxID;
            this.SinceIDString = d.ToString("since_id_str");
            this.RefreshUrl = d.ToString("refresh_url");
            this.NextResults = d.ToString("next_results");
            this.Count = d.ToInt32("count") ?? this.Count;
            this.CompletedIn = d.ToDouble("completed_in") ?? this.CompletedIn;
            this.Query = d.ToString("query");
        }
    }
}
